import { ReactNode } from "react"
import { Navigate } from "react-router-dom"
import React from 'react'

const WithLogin = (WrapperComponent: React.FC) => {

	return () => {
		
		const token = localStorage.getItem('token')

		if (token) {
			return <WrapperComponent></WrapperComponent>
		}

		return <Navigate to="/login" replace></Navigate>

	}
}

export default WithLogin